<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>地市福利添加</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all" />
</head>
<body class="childrenBody">
	<form class="layui-form">
		<div class="layui-form-item">
			<label class="layui-form-label">服务分类名称</label>
			<div class="layui-input-block" style="width: 20%">
				<input type="text" class="layui-input name" lay-verify="required" name="name" placeholder="请输入服务分类名称">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="addCategorys">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		</div>
	</form>
	<script type="text/javascript" src="/js/jquery-1.11.2.min.js"></script>
	<script type="text/javascript" src="/plugins/layui/layui.js"></script>
<!-- 	<script type="text/javascript" src="/js/user/newsAdd.js"></script> -->
	
	<script type="text/javascript">
	layui.config({
		base : "js/"
	}).use(['form','layer','jquery','layedit','laydate'],function(){
		var form = layui.form,
			layer = parent.layer === undefined ? layui.layer : parent.layer,
			laypage = layui.laypage,
			layedit = layui.layedit,
			laydate = layui.laydate,
			$ = layui.jquery;

		//创建一个编辑器
	 	form.on("submit(addCategorys)",function(data){
	 		var datas=data.field;
	 		alert(JSON.stringify(datas));
	 		var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
	 		$.ajax({  
	            type: "POST",  
	            url:"/categorys",  
	            data:JSON.stringify(datas),// 序列化表单值  
	         //   dataType: "json",
	           // contentType:"application/json",
	           
	            success: function(data) { 
	            	
	            	top.layer.close(index);
          			top.layer.msg("添加成功！");
           			layer.closeAll("iframe");
          	 		//刷新父页面
          	 		parent.location.reload();
	            
	            
	            } ,
		 		 error: function(request) {  
		             alert("Connection error");  
		         } 
	        }); 
	 	})
		
	})
	</script>
</body>
</html>

